package ngames.com.sushitv.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;

import org.w3c.dom.Text;

import java.util.ArrayList;
import java.util.List;

import ngames.com.sushitv.AppApplication;
import ngames.com.sushitv.R;
import ngames.com.sushitv.activity.AnimeSingleActivity;
import ngames.com.sushitv.base.BaseListAdapter;
import ngames.com.sushitv.entity.ItemVideo;
import ngames.com.sushitv.entity.genres;

/**
 * Created by edmond on 16-8-9.
 */
public class AnimeIntroAdapter extends BaseListAdapter<ItemVideo> {
    /*private Context context;
    private ArrayList<Integer> integerList;
    private LayoutInflater inflater;*/

    public AnimeIntroAdapter(Context context, ArrayList<ItemVideo> genres){
        super(context,genres);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ItemVideoHolder(mInflater.inflate(R.layout.item_anime_intro, parent, false));
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        ItemVideoHolder viewHolder = (ItemVideoHolder) holder;
        viewHolder.setData(position);
    }

    @Override
    public int getItemCount() {
        return mDataList.size();
    }

    class ItemVideoHolder extends RecyclerView.ViewHolder{
        private TextView textView;
        public ItemVideoHolder(View itemView) {
            super(itemView);
            textView= (TextView) itemView.findViewById(R.id.text_animeIntro);
        }

        public void setData(int data) {
            final ItemVideo i=mDataList.get(data);
            textView.setText(i.getEpisode());
            textView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    AppApplication.setmVsId(i.getId());
                    Intent intent=new Intent(mContext,AnimeSingleActivity.class);
                    mContext.startActivity(intent);
                }
            });
        }
    }
}
